package com.lej.dataservice.club.http.interceptor

import com.lej.core.base.app
import com.lej.dataservice.club.http.NetworkUtil
import okhttp3.Interceptor
import okhttp3.Response
import java.io.IOException

/**发送数据*/
class ErrorInterceptor : Interceptor {
    @Throws(IOException::class)
    override fun intercept(chain: Interceptor.Chain): Response {
        val request = chain.request()
        val response = chain.proceed(request)
        val code = response.code
        if (code == 504 || !NetworkUtil.isNetworkAvailable(app)) {
            return response.newBuilder().message("请检查网络链接").build()
        }
        return response
    }
}